<?php
session_cache_expire(999999999);
if (!isset($_SESSION)) {
    session_start();
}
ob_start();
//session_cache_expire(999999999);
?>

<html>
    <body>
        <script type="text/javascript">
            var w = 0;
            var h = 0;
            if (window.innerWidth) {w = window.innerWidth; h = window.innerHeight;}
            else if (document.all) {w = document.body.clientWidth; h = document.body.clientHeight;}
        </script>
    </body>
</html>
<?php
$CountFile = "index.log";
$CF = fopen($CountFile, "r");
$Hits = fread($CF, filesize($CountFile));
fclose($CF);
$Hits++;

$CF = fopen($CountFile, "w");
fwrite($CF, $Hits);
fclose($CF);
echo($Hits);






$myWidth = "<script>  
document.write(w); </script>";
$myHeight = "<script>  
document.write(h); </script>";

// echo $myWidth." - ".$myHeight.'</br>' ;



function ismobile() {
    $is_mobile = '0';

    if (preg_match('/(android|up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
        $is_mobile = 1;
    }

    if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']), 'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
        $is_mobile = 1;
    }

    $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
    $mobile_agents = array('w3c ', 'acs-', 'alav', 'alca', 'amoi', 'andr', 'audi', 'avan', 'benq', 'bird', 'blac', 'blaz', 'brew', 'cell', 'cldc', 'cmd-', 'dang', 'doco', 'eric', 'hipt', 'inno', 'ipaq', 'java', 'jigs', 'kddi', 'keji', 'leno', 'lg-c', 'lg-d', 'lg-g', 'lge-', 'maui', 'maxo', 'midp', 'mits', 'mmef', 'mobi', 'mot-', 'moto', 'mwbp', 'nec-', 'newt', 'noki', 'oper', 'palm', 'pana', 'pant', 'phil', 'play', 'port', 'prox', 'qwap', 'sage', 'sams', 'sany', 'sch-', 'sec-', 'send', 'seri', 'sgh-', 'shar', 'sie-', 'siem', 'smal', 'smar', 'sony', 'sph-', 'symb', 't-mo', 'teli', 'tim-', 'tosh', 'tsm-', 'upg1', 'upsi', 'vk-v', 'voda', 'wap-', 'wapa', 'wapi', 'wapp', 'wapr', 'webc', 'winw', 'winw', 'xda', 'xda-');

    if (in_array($mobile_ua, $mobile_agents)) {
        $is_mobile = 1;
    }

    if (isset($_SERVER['ALL_HTTP'])) {
        if (strpos(strtolower($_SERVER['ALL_HTTP']), 'OperaMini') > 0) {
            $is_mobile = 1;
        }
    }

    if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows') > 0) {
        $is_mobile = 0;
    }
    return $is_mobile;
}

//include 'bloghoctap.net_Browser.php';
//echo $w;
//$browser= new Browser();
//echo $browser->getBrowser();


function curPageName() {
    return $_SERVER["SCRIPT_NAME"];
}

//echo "The current page name is ".curPageName();
//require_once "caching.php";
//$cache = new SimpleCache();
//$lang = $cache->get('lang');
//if($lang=='')
//	$lang='EN';
//if($browser->getBrowser() == Browser::BROWSER_ANDROID || $browser->getBrowser() == Browser::BROWSER_IPHONE){
if (ismobile() == 1) {
    $addressbrowser = "elitech.myapprove.com";
    //$addressbrowser = $_SERVER['SERVER_NAME'];
    $temp = explode(".", $addressbrowser);
    //echo "temp == ".$temp[0];
    //$connection = mysql_connect("1.234.53.52", "cam", "5678" ) ;
    $connection = mysql_connect("localhost", "root", "root");
    mysql_select_db("elihan", $connection);
    mysql_query("set names 'utf8'");
    $selectdatabase = mysql_query("SELECT am.DatabaseName,am.Logo from ac_eli_manager am where am.KeyName='$temp[0]' and am.`Status` = 2");
    $result = mysql_fetch_assoc($selectdatabase);

    $_SESSION['Logo'] = $result[Logo];
    $_SESSION['db'] = $result[DatabaseName];
    //	echo "  database == ".$_SESSION['db'];

    mysql_close($connection);
    $_SESSION['browser'] = "ERP";
    if (!isset($_SESSION['lang']))
        $_SESSION['lang'] = $lang;

    header('Location: ERP-PC/login.php');
    //echo "<meta http-equiv='refresh' content='0; url=ERP-Phone/index.php' /> ";
}else {
    $addressbrowser = "elitech.myapprove.com";
    //$addressbrowser = $_SERVER['SERVER_NAME'];
    $temp = explode(".", $addressbrowser);
    //echo "temp == ".$temp[0];
    //$connection = mysql_connect("1.234.53.52", "cam", "5678" ) ;
    $connection = mysql_connect("localhost", "root", "root");
    mysql_select_db("elihan", $connection);
    mysql_query("set names 'utf8'");
    $selectdatabase = mysql_query("SELECT am.DatabaseName,am.Logo from ac_eli_manager am where am.KeyName='$temp[0]' and am.`Status` = 2");
    $result = mysql_fetch_assoc($selectdatabase);

    $_SESSION['Logo'] = $result[Logo];
    $_SESSION['db'] = $result[DatabaseName];
    //	echo "  database == ".$_SESSION['db'];

    mysql_close($connection);
    $_SESSION['browser'] = "ERP";
    if (!isset($_SESSION['lang']))
        $_SESSION['lang'] = $lang;
    //echo " chuyen trang php-pc";
    include 'ERP-PC/log.php';
    header('Location: ERP-PC/login.php');
    //echo "<meta http-equiv='refresh' content='0; url=ERP-PC/index.php' /> ";
}
/* if($browser->getBrowser() == Browser::BROWSER_FIREFOX)
  echo "This is firefox";
  if($browser->getBrowser() == Browser::BROWSER_CHROME)
  echo "This is Chrome";
  if($browser->getBrowser() == Browser::BROWSER_OPERA)
  echo "This is Opera";
  if($browser->getBrowser() == Browser::BROWSER_IE)
  echo "This is Internet Explore"; */
ob_flush();
?>
